<html>
<head>
    <title>风险责任清单</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../../../style.css">

    <style>
        body {
            background: #F0F2F6;
        }

        .main-head {
            background: #fff;
            padding-left: 10px;
            padding-top: 10px;
            margin-bottom: 0px;
            border: solid 1px #fff;
        }

        .chart-outer {
            height: 200px;
        }

        img {
            width: 30px;
            width: 32px;
        }

        td {
            text-align: center;
            height: 50px; /*这里需要自己调整，根据自己的需求调整高度*/
            position: relative;
        }

        td[class=first] {
            width: 100px;
        }

        td[class=first]:before {
            content: "";
            position: absolute;
            width: 1px;
            height: 160px;
            top: 0;
            left: 0;
            background-color: #000;
            display: block;
            transform: rotate(-73deg);
            transform-origin: top;
            -ms-transform: rotate(-73deg);
            -ms-transform-origin: top;
        }

        .title1 {
            position: absolute;
            top: 0px;
            right: 0px;
        }

        .title2 {
            position: absolute;
            top: 26px;
            right: 70px;
        }

        .el-dialog {
            position: absolute;
            top: 50%;
            left: 50%;
            margin: 0 !important;
            transform: translate(-50%, -50%);
            display: flex;
            flex-direction: column;
            max-height: calc(100% - 30px);
            width: 100%;
            /*max-width: calc(100% - 30px);*/
        }
    </style>
</head>
<body>
<div class="page" id="page-monitor">
    <div class="page-title">公文推送,发送公文</div>
    <div class="page-main">
        <div class="main-head">
            <el-form :inline="true" size="small" :model="searchForm">
                <el-form-item label="公文号">
                    <el-input placeholder="公文号" style="width: 150px;" v-model="DocNo"></el-input>
                </el-form-item>
                <el-form-item label="发送时间" prop="startTime">
                    <el-col :span="11">
                        <el-date-picker type="date" placeholder="开始时间" v-model="startTime"
                                        value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
                    </el-col>
                    <el-col class="line" :span="2">-</el-col>
                    <el-col :span="11">
                        <el-date-picker type="date" placeholder="结束时间" v-model="endTime"
                                        value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
                    </el-col>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="btnSearch">查询</el-button>
                    <el-button type="success" @click="btnAdd">新增</el-button>
                </el-form-item>
            </el-form>
        </div>
        <el-table :data="tableData" :stripe="true" :border="true" size="mini" style="width: 100%">
            <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
            <el-table-column prop="DocCompany" label="建档单位" align="center"></el-table-column>
            <el-table-column prop="DocDepartmentName" label="建档部门" align="center"></el-table-column>
            <el-table-column prop="DocTime" label="建档日期" align="center">
                <template slot-scope="scope" v-if="scope.row.DocTime">
                    <el-tag size="medium">{{scope.row.DocTime.replace("T"," ").substr(0,10)}}</el-tag>
                </template>
            </el-table-column>
            <el-table-column prop="DocName" label="公文名称" align="center"></el-table-column>
            <el-table-column prop="DocNo" label="公文号" align="center"></el-table-column>
            <el-table-column prop="file" label="下载文件">
                <template slot-scope="scope">
                    <el-button @click="report(scope.row.file)" size="small" type="primary">下载</el-button>
                </template>
            </el-table-column>
            <!--<el-table-column prop="endTime" label="计划结束时间" align="center">-->
            <!--<template slot-scope="scope" v-if="scope.row.endTime">-->
            <!--<el-tag size="medium">{{scope.row.endTime.replace("T"," ").substr(0,10)}}</el-tag>-->
            <!--</template>-->
            <!--</el-table-column>-->
            <!--<el-table-column prop="checkDepartmentCount" label="检查单位数" align="center"></el-table-column>-->
            <!--<el-table-column prop="actualCount" label="实际检查数量" align="center"></el-table-column>-->
            <!--<el-table-column label="状态" prop="status" align="center">-->
            <!--<template slot-scope="scope">-->
            <!--<template v-if="scope.row.state==0">-->
            <!--<el-tag type="info">未检查</el-tag>-->
            <!--</template>-->
            <!--<template v-if="scope.row.state==1">-->
            <!--<el-tag>检查中</el-tag>-->
            <!--</template>-->
            <!--<template v-if="scope.row.state==2">-->
            <!--<el-tag type="success">检查完成</el-tag>-->
            <!--</template>-->
            <!--</template>-->
            <!--</el-table-column>-->
            <el-table-column label="操作" align="center" width="280">
                <template slot-scope="scope">
                    <!--<el-button @click="showDetail(scope.row.trainingId)" round size="mini" icon="el-icon-search"-->
                    <!--type="primary">详情-->
                    <!--</el-button>-->
                    <el-button round icon="el-icon-setting" size="mini"
                               @click="handleEdit(scope.row.DocId)" type="info">编辑
                    </el-button>
                    <el-button @click="delPlan(scope.row.Id)" round size="mini" icon="el-icon-delete"
                               type="danger">删除
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="page-footer">
            <el-pagination background layout="prev, pager, next" :pagesize="pagesize" :total="totalCount"
                           :current-page.sync="pageno" @current-change="onChangePage">
            </el-pagination>
        </div>
    </div>

    <el-dialog :title="'添加'" :visible.sync="addVisible" :show-close="false" style="display: none">
        <el-row>
            <el-col :span="8">
                <el-form ref="addForm" :model="addForm" label-width="120px">
                    <el-form-item label="建档单位" prop="DocName" :rules="[
                             {required:true,message:'建档单位!',trigger:'blur'}]">
                        <el-input v-model="addForm.DocCompany"></el-input>
                    </el-form-item>
                    <el-form-item label="建档部门" prop="DocDepartment" :rules="[
                             {required:true,message:'建档部门!',trigger:'blur'}]">
                        <el-select v-model="addForm.DocDepartment" style="width: 200px">
                            <el-option
                                    v-for="item in DepartmentData"
                                    :key="item.DepartmentID"
                                    :label="item.DepartmentName"
                                    :value="item.DepartmentID">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="建档人员" prop="DocStaff" :rules="[
                             {required:true,message:'建档人员!',trigger:'blur'}]">
                        <el-select v-model="addForm.DocStaff" style="width: 200px">
                            <el-option
                                    v-for="item in userData"
                                    :key="item.Id"
                                    :label="item.userName"
                                    :value="item.Id" v-if="item.isAccept==1">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="建档日期" prop="DocTime" :rules="[
                             {required:true,message:'建档日期!',trigger:'blur'}]">
                        <el-date-picker type="date" placeholder="建档日期" v-model="addForm.DocTime"
                                        value-format="yyyy-MM-dd" style="width: 200px;"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="公文名称" prop="DocName" :rules="[
                             {required:true,message:'公文名称!',trigger:'blur'}]">
                        <el-input v-model="addForm.DocName"></el-input>
                    </el-form-item>
                    <el-form-item label="公文号" prop="DocNo" :rules="[
                             {required:true,message:'公文号!',trigger:'blur'}]">
                        <el-input v-model="addForm.DocNo"></el-input>
                    </el-form-item>

                    <el-form-item label="文件上传">
                        <!--iot.hzcando.com-->
                        <el-upload
                                class="upload-demo"
                                drag
                                action="http://iot.hzcando.com/api/idm/v1/GovernmentDoc/DocAdd"
                                :headers="headers"
                                name="file"
                                :data="addForm"
                                :limit="1"
                                :auto-upload="false"
                                ref="add">
                            <i class="el-icon-upload"></i>
                            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                            <div class="el-upload__tip" slot="tip">只能上传jpg/png文件</div>
                        </el-upload>
                    </el-form-item>
                </el-form>
            </el-col>
            <el-col :span="6">
                <el-divider content-position="right">
                    <el-button type="primary" icon="el-icon-plus" size="small" @click="userCheck">添加人员</el-button>
                </el-divider>
                <table width="100%" cellspacing="1" border="1">
                    <tr>
                        <th>姓名</th>
                        <th>手机号</th>
                        <th>部门</th>
                        <th>操作</th>
                    </tr>
                    <template v-if="userDatas">
                        <tr v-for="(item,i) in userDatas" style="font-size: 12px">
                            <td>{{item.userName}}</td>
                            <td>{{item.Telephone}}</td>
                            <td>{{item.DepartmentName}}</td>
                            <td>
                                <el-button @click="del_userDatas(i)" type="primary" size="mini">删除</el-button>
                            </td>
                        </tr>
                    </template>
                </table>
            </el-col>
            <el-col :span="9">
                <el-divider content-position="right">
                    <el-button type="primary" icon="el-icon-plus" size="small" @click="projectCheck">添加企业</el-button>
                </el-divider>
                <table width="100%" cellspacing="1" border="1">
                    <tr>
                        <th>企业名称</th>
                        <th>联系方式</th>
                        <th>省</th>
                        <th>市</th>
                        <th>区</th>
                        <th>地址</th>
                        <th>操作</th>
                    </tr>
                    <template v-if="projectDatas">
                        <tr v-for="(item,i) in projectDatas" style="font-size: 12px">
                            <td>{{item.projectName}}</td>
                            <td>{{item.phone}}</td>
                            <td>{{item.province}}</td>
                            <td>{{item.city}}</td>
                            <td>{{item.zone}}</td>
                            <td>{{item.address}}</td>
                            <td>
                                <el-button @click="del_projectDatas(i)" type="primary" size="mini">删除</el-button>
                            </td>
                        </tr>
                    </template>
                </table>
            </el-col>
        </el-row>


        <div slot="footer" class="dialog-footer">
            <el-button @click="addVisible=false">取消</el-button>
            <el-button @click="plan_submit('add')">确定</el-button>
        </div>
    </el-dialog>


    <el-dialog :title="'编辑'" :visible.sync="editVisible" :show-close="false"  style="display: none">
        <el-row>
            <el-col :span="8">
                <el-form ref="editForm" :model="editForm" label-width="120px">
                    <el-form-item label="建档单位" prop="DocName" :rules="[
                             {required:true,message:'建档单位!',trigger:'blur'}]">
                        <el-input v-model="editForm.DocCompany"></el-input>
                    </el-form-item>

                    <el-form-item label="建档部门" prop="DocDepartment" :rules="[
                             {required:true,message:'建档部门!',trigger:'blur'}]">
                        <el-select v-model="editForm.DocDepartment" style="width: 200px">
                            <el-option
                                    v-for="item in DepartmentData"
                                    :key="item.DepartmentID"
                                    :label="item.DepartmentName"
                                    :value="item.DepartmentID">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="建档人员" prop="DocStaff" :rules="[
                             {required:true,message:'建档人员!',trigger:'blur'}]">
                        <el-select v-model="editForm.DocStaff" style="width: 200px">
                            <el-option
                                    v-for="item in userData"
                                    :key="item.Id"
                                    :label="item.userName"
                                    :value="item.Id" v-if="item.isAccept==1">
                            </el-option>
                        </el-select>
                    </el-form-item>

                    <el-form-item label="建档日期" prop="DocTime" :rules="[
                             {required:true,message:'建档日期!',trigger:'blur'}]">
                        <el-date-picker type="date" placeholder="建档日期" v-model="editForm.DocTime"
                                        value-format="yyyy-MM-dd" style="width: 200px;"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="公文名称" prop="DocName" :rules="[
                             {required:true,message:'公文名称!',trigger:'blur'}]">
                        <el-input v-model="editForm.DocName"></el-input>
                    </el-form-item>
                    <el-form-item label="公文号" prop="DocNo" :rules="[
                             {required:true,message:'公文号!',trigger:'blur'}]">
                        <el-input v-model="editForm.DocNo"></el-input>
                    </el-form-item>

                    <el-form-item label="文件上传">
                        <!--iot.hzcando.com-->
                        <el-upload
                                class="upload-demo"
                                drag
                                action="http://iot.hzcando.com/api/idm/v1/GovernmentDoc/DocUpdate"
                                :headers="headers"
                                name="file"
                                :data="editForm"
                                :limit="1"
                                :auto-upload="false"
                                ref="edit">
                            <i class="el-icon-upload"></i>
                            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                            <div class="el-upload__tip" slot="tip">只能上传jpg/png文件</div>
                        </el-upload>
                    </el-form-item>
                </el-form>
            </el-col>
            <el-col :span="6">
                <el-divider content-position="right">
                    <el-button type="primary" icon="el-icon-plus" size="small" @click="userCheck">添加人员</el-button>
                </el-divider>
                <table width="100%" cellspacing="1" border="1">
                    <tr>
                        <th>姓名</th>
                        <th>手机号</th>
                        <th>部门</th>
                        <th>操作</th>
                    </tr>
                    <template v-if="userDatas">
                        <tr v-for="(item,i) in userDatas" style="font-size: 12px">
                            <td>{{item.userName}}</td>
                            <td>{{item.Telephone}}</td>
                            <td>{{item.DepartmentName}}</td>
                            <td>
                                <el-button @click="del_userDatas(i)" type="primary" size="mini">删除</el-button>
                            </td>
                        </tr>
                    </template>
                </table>
            </el-col>
            <el-col :span="9">
                <el-divider content-position="right">
                    <el-button type="primary" icon="el-icon-plus" size="small" @click="projectCheck">添加企业</el-button>
                </el-divider>
                <table width="100%" cellspacing="1" border="1">
                    <tr>
                        <th>企业名称</th>
                        <th>联系方式</th>
                        <th>省</th>
                        <th>市</th>
                        <th>区</th>
                        <th>地址</th>
                        <th>操作</th>
                    </tr>
                    <template v-if="projectDatas">
                        <tr v-for="(item,i) in projectDatas" style="font-size: 12px">
                            <td>{{item.projectName}}</td>
                            <td>{{item.phone}}</td>
                            <td>{{item.province}}</td>
                            <td>{{item.city}}</td>
                            <td>{{item.zone}}</td>
                            <td>{{item.address}}</td>
                            <td>
                                <el-button @click="del_projectDatas(i)" type="primary" size="mini">删除</el-button>
                            </td>
                        </tr>
                    </template>
                </table>
            </el-col>
        </el-row>


        <div slot="footer" class="dialog-footer">
            <el-button @click="editVisible=false">取消</el-button>
            <el-button @click="plan_esubmit('edit')">确定</el-button>
        </div>
    </el-dialog>


    <!--<el-dialog title="检查内容" :visible.sync="checkVisible" :show-close="false" width="50%">-->
    <!--<el-table :data="PlanData" :stripe="true" :border="true" size="mini"-->
    <!--ref="multipleTable"-->
    <!--tooltip-effect="dark"-->
    <!--style="width: 100%"-->
    <!--@selection-change="checkChange" append-to-body>-->
    <!--<el-table-column-->
    <!--type="selection"-->
    <!--width="55">-->
    <!--</el-table-column>-->
    <!--<el-table-column type="index" label="序号" width="50" align="center"></el-table-column>-->
    <!--<el-table-column prop="bussinessTypeName" label="行业大类" align="center"></el-table-column>-->
    <!--<el-table-column prop="patrolcontent" label="检查内容" align="center">-->
    <!--</el-table-column>-->
    <!--</el-table>-->
    <!--<div slot="footer" class="dialog-footer">-->
    <!--<el-button @click="checkVisible=false">取消</el-button>-->
    <!--<el-button @click="checkVisible=false">确定</el-button>-->
    <!--</div>-->
    <!--</el-dialog>-->

    <el-dialog title="检查人员" :visible.sync="userVisible" :show-close="false" width="50%" style="display: none">
        <el-table :data="userData" :stripe="true" :border="true" size="mini"
                  ref="multipleTable"
                  tooltip-effect="dark"
                  style="width: 100%"
                  @selection-change="userChange" append-to-body>
            <el-table-column
                    type="selection"
                    width="55">
            </el-table-column>
            <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
            <el-table-column prop="userName" label="姓名" align="center"></el-table-column>
            <el-table-column prop="Telephone" label="手机号" align="center"></el-table-column>
            <el-table-column prop="DepartmentName" label="部门" align="center"></el-table-column>
        </el-table>
        <div slot="footer" class="dialog-footer">
            <el-button @click="userVisible=false">取消</el-button>
            <el-button @click="userVisible=false">确定</el-button>
        </div>
    </el-dialog>

    <el-dialog title="检查企业" :visible.sync="projectVisible" :show-close="false" width="50%" style="display: none">
        <el-form :inline="true" size="small" :model="searchForm">

            <el-form-item label="省份">
                <el-input placeholder="省份" style="width: 150px;" v-model="province"></el-input>
            </el-form-item>
            <el-form-item label="城市">
                <el-input placeholder="城市" style="width: 150px;" v-model="city"></el-input>
            </el-form-item>
            <el-form-item label="区域">
                <el-input placeholder="区域" style="width: 150px;" v-model="zone"></el-input>
            </el-form-item>
            <el-form-item label="企业名称">
                <el-input placeholder="企业名称" style="width: 150px;" v-model="projectName"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="projectSearch">查询</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="ProjectData" :stripe="true" :border="true" size="mini"
                  ref="multipleTable"
                  tooltip-effect="dark"
                  style="width: 100%"
                  @selection-change="projectChange" append-to-body>
            <el-table-column
                    type="selection"
                    width="55">
            </el-table-column>
            <el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
            <el-table-column prop="projectName" label="企业名称" align="center"></el-table-column>
            <el-table-column prop="phone" label="联系方式" align="center"></el-table-column>
            <el-table-column prop="province" label="省" align="center"></el-table-column>
            <el-table-column prop="city" label="市" align="center"></el-table-column>
            <el-table-column prop="zone" label="区" align="center"></el-table-column>
            <el-table-column prop="address" label="地址" align="center"></el-table-column>
        </el-table>
        <div slot="footer" class="dialog-footer">
            <el-button @click="projectVisible=false">取消</el-button>
            <el-button @click="projectVisible=false">确定</el-button>
        </div>
    </el-dialog>
</div>

<script type='text/javascript' src='../../../assets/bundle.js' charset='utf-8'></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script type='text/javascript' src='../../../assets/jquery-1.11.2.min.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../assets/echarts.min.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../js/common.js' charset='utf-8'></script>
<script type='text/javascript' src='../../../js/component.js' charset='utf-8'></script>

<script>

    var vuePage = new Vue({
        el: '#page-monitor',
        data: {
            tableData: [],
            searchForm: {
                pagesize: 10,
                totalCount: 10,
                pageno: 1,
                UserId: SiteConfig.account.id,
                trainFlag: ''
            },
            editMod: false,
            addVisible: false,
            editVisible: false,
            innerVisible: false,

            checkVisible: false,
            userVisible: false,
            projectVisible: false,
            addForm: {},
            editForm: {},
            sel_user: [],
            multipleSelection: [],
            child: [],
            departMent: [],
            file_list: '',
            userDetail: [],
            DangerousData: [
                {Name: '直接选择或搜索选择', Id: 0},
                {Name: '重点检查', Id: 1},
                {Name: '一般检查', Id: 2},
                {Name: '专项检查', Id: 3}
            ],
            planName: '',
            planType: '',
            pagesize: 10,
            totalCount: 0,
            pageno: 1,
            PlanData: [],
            userData: [],
            ProjectData: [],
            DepartmentData: [],
            checkDatas: [],
            projectDatas: [],
            userDatas: [],
            projectName: '',
            province: '',
            city: '',
            zone: '',
            headers: {
                uid: '',
                token: '',
            },
            endTime: '',
            startTime: '',
            DocNo: ''

        },
        methods: {
            cancelClick(name) {
                switch (name) {
                    case 'addForm':
                        this.addForm = {};
                        this.addVisible = false;
                        break;
                    case 'editForm':
                        this.editVisible = false;
                        this.editForm = {};
                        break;
                }
            },
            report: function (filename) {
                window.open(SiteConfig.webApiset + filename);
            },
            projectSearch: function () {
                this.projectList();
            },
            btnSearch: function () {
                this.getTrain();
            },
            onChangePage(page) {
                this.pageno = page;
                this.getTrain();
            },
            btnAdd() {
                this.addVisible = true;
                this.addForm = {};
                this.projectDatas = {};
                this.userDatas = {};
                this.editMod = false;
            },
            showUser() {
                this.innerVisible = true;
            },
            del_checkDatas(index) {
                this.checkDatas.splice(index, 1);
            },
            del_projectDatas(index) {
                this.projectDatas.splice(index, 1);
            },
            del_userDatas(index) {
                this.userDatas.splice(index, 1);
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },

            checkCheck() {
                this.checkVisible = true;
            },
            userCheck() {
                this.userVisible = true;
            },
            projectCheck() {
                this.projectVisible = true;
            },
            projectChange(val) {
                this.projectDatas = val;
                console.log(this.projectDatas)
            },
            userChange(val) {
                this.userDatas = val;
                console.log(this.userDatas)
            },
            checkChange(val) {
                this.checkDatas = val;
                console.log(this.checkData)
            },

            filterTag(value, row) {
                return row.attributes.departmentId === value;
            },
            plan_submit(name) {
                if (!this.addForm.DocCompany) {
                    this.$message({type: 'error', message: '建档单位不能为空'})
                    return;
                }
                if (!this.addForm.DocDepartment) {
                    this.$message({type: 'error', message: '建档部门不能为空'})
                    return;
                }
                if (!this.addForm.DocStaff) {
                    this.$message({type: 'error', message: '建档人员不能为空'})
                    return;
                }
                if (!this.addForm.DocTime) {
                    this.$message({type: 'error', message: '建档日期不能为空'})
                    return;
                }
                if (!this.addForm.DocName) {
                    this.$message({type: 'error', message: '公文名称不能为空'})
                    return;
                }
                if (!this.addForm.DocNo) {
                    this.$message({type: 'error', message: '公文号不能为空'})
                    return;
                }

                if (this.userDatas <= 0) {
                    this.$message({type: 'error', message: '请选择检查人员！'});
                    return;
                }
                if (this.projectDatas <= 0) {
                    this.$message({type: 'error', message: '请选择企业！'});
                    return;
                }


                let checks = [], users = [], projects = [];
                try {
                    // for (let temp of this.checkDatas) {
                    //     checks.push(temp.Id);
                    // }

                    for (let temp of this.userDatas) {
                        users.push(temp.Id);
                    }
                    for (let temp of this.projectDatas) {
                        projects.push(temp.projectNo);
                    }
                } catch (e) {
                    this.$message({type: 'error', message: e});
                }
                // this.addForm.contents = checks.join(',');
                this.addForm.peoples = users.join(',');
                this.addForm.companys = projects.join(',');
                this.addForm.UserId = SiteConfig.account.id;

                this.$refs[name].submit();
                this.addVisible = false;
                this.$message({
                    message: '添加成功！',
                    type: 'success'
                });
                this.getTrain();
            },
            plan_esubmit(name) {
                if (!this.editForm.DocCompany) {
                    this.$message({type: 'error', message: '建档单位不能为空'})
                    return;
                }
                if (!this.editForm.DocDepartment) {
                    this.$message({type: 'error', message: '建档部门不能为空'})
                    return;
                }
                if (!this.editForm.DocStaff) {
                    this.$message({type: 'error', message: '建档人员不能为空'})
                    return;
                }
                if (!this.editForm.DocTime) {
                    this.$message({type: 'error', message: '建档日期不能为空'})
                    return;
                }
                if (!this.editForm.DocName) {
                    this.$message({type: 'error', message: '公文名称不能为空'})
                    return;
                }
                if (!this.editForm.DocNo) {
                    this.$message({type: 'error', message: '公文号不能为空'})
                    return;
                }

                if (this.userDatas <= 0) {
                    this.$message({type: 'error', message: '请选择检查人员！'});
                    return;
                }
                if (this.projectDatas <= 0) {
                    this.$message({type: 'error', message: '请选择企业！'});
                    return;
                }


                let checks = [], users = [], projects = [];
                try {
                    // for (let temp of this.checkDatas) {
                    //     checks.push(temp.Id);
                    // }

                    for (let temp of this.userDatas) {
                        users.push(temp.Id);
                    }
                    for (let temp of this.projectDatas) {
                        projects.push(temp.projectNo);
                    }
                } catch (e) {
                    this.$message({type: 'error', message: e});
                }
                // this.addForm.contents = checks.join(',');
                this.editForm.peoples = users.join(',');
                this.editForm.companys = projects.join(',');
                this.editForm.UserId = SiteConfig.account.id;


                this.$refs[name].submit();
                this.editVisible = false;
                this.$message({
                    message: '修改成功！',
                    type: 'success'
                });
                this.getTrain();
            },
            delPlan(id) {
                this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    HttpUtil.get('GovernmentDoc/DocDelete', {Id: id}).success((r) => {
                        this.$message({
                            type: 'success',
                            message: '删除成功!'
                        });
                        this.getTrain();
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            showDetail(id) {
                this.detailVisible = true;
                this.getDetail(id);
            },
            handleEdit(DocId) {

                HttpUtil.get('GovernmentDoc/DocList', {
                    DocId: DocId,
                    UserId: SiteConfig.account.id
                }).success((r) => {
                    if (r.state == 0) {
                        this.editForm = {
                            Id: r.data[0].docdata[0].Id,
                            DocId: r.data[0].docdata[0].DocId,
                            DocCompany: r.data[0].docdata[0].DocCompany,
                            DocStaff: parseInt(r.data[0].docdata[0].DocStaff),
                            DocDepartment: parseInt(r.data[0].docdata[0].DocDepartment),
                            DocTime: r.data[0].docdata[0].DocTime,
                            DocName: r.data[0].docdata[0].DocName,
                            DocNo: r.data[0].docdata[0].DocNo,
                            fileIds: [],
                            UserId: r.data[0].docdata[0].UserId,
                            file: r.data[0].docdata[0].file,
                        };


                        // this.checkDatas = r.data[1].checkDatas;
                        // var checkDatas = r.data[1].checkDatas;
                        // var BusinessListData = this.BusinessList;
                        // for (var i = 0; i < checkDatas.length; i++) {
                        //     for (var j = 0; j < BusinessListData.length; j++) {
                        //         if (checkDatas[i].bussinessType == BusinessListData[j].cid) {
                        //             checkDatas[i].bussinessTypeName = BusinessListData[j].cname;
                        //         }
                        //     }
                        // }

                        // vuePage.checkDatas = checkDatas;
                        vuePage.projectDatas = r.data[1].companyDatas;
                        // this.userDatas = r.data[3].userDatas;
                        var userData = r.data[2].staffDatas;
                        var DepartmentData = this.DepartmentData;
                        for (var i = 0; i < userData.length; i++) {
                            for (var j = 0; j < DepartmentData.length; j++) {
                                if (userData[i].departmentId == DepartmentData[j].DepartmentID) {
                                    userData[i].DepartmentName = DepartmentData[j].DepartmentName;
                                }
                            }
                        }
                        vuePage.userDatas = userData;
                        this.editVisible = true;
                        this.editMod = true;
                    }
                    else {
                        this.$message({
                            type: 'error',
                            message: r.errMsg
                        })
                    }

                })
            },
            getTrain() {
                var param = {};
                if (this.DocNo)
                    param.DocNo = this.DocNo;
                if (this.startTime)
                    param.startTime = this.startTime;
                if (this.endTime)
                    param.endTime = this.endTime;


                param.UserId = SiteConfig.account.id;
                param.pageno = this.pageno;
                param.pagesize = this.pagesize;

                // this.tableData = [{
                //     DocDepartmentName: '资料科',
                //     DocStaff: 10,
                //     DocTime: '2019-12-11 15:45:34',
                //     DocName: '环保局',
                //     DocNo: '环办[2019]119号'
                //
                // }]
                HttpUtil.get('GovernmentDoc/DocList', param).success((res) => {
                    var DocList = res.data;
                    this.totalCount = res.total;
                    var DepartmentData = this.DepartmentData;
                    for (var i = 0; i < DocList.length; i++) {
                        for (var j = 0; j < DepartmentData.length; j++) {
                            if (DocList[i].DocDepartment == DepartmentData[j].DepartmentID) {
                                DocList[i].DocDepartmentName = DepartmentData[j].DepartmentName;
                            }
                        }
                    }
                    this.tableData = DocList;
                })
            },
            getFile() {
                HttpUtil.get('Training/FileList', {UserId: SiteConfig.account.id}).success((r) => {
                    this.file_list = r.data;
                })
            },
            getDetail(id) {
                HttpUtil.get('Training/PeopleDetail', {trainingId: id}).success((r) => {
                    this.userDetail = r.data;
                })
            },
            projectList() {
                var param = {};

                if (this.projectName)
                    param.projectName = this.projectName;
                if (this.province)
                    param.province = this.province;
                if (this.city)
                    param.city = this.city;
                if (this.zone)
                    param.zone = this.zone;
                param.UserId = SiteConfig.account.id;
                param.pageno = 1;
                param.pagesize = 1000;
                HttpUtil.get('Project/List', param).success((res) => {
                    vuePage.ProjectData = res.data;
                });
            }
        },
        created: function () {
            this.headers = {
                uid: SiteConfig.account.uId,
                token: SiteConfig.account.accessToken
            }
            HttpUtil.get('CodeController/BusinessList').success((r) => {
                if (r.state == 0) {
                    vuePage.BusinessList = r.data;
                    vuePage.BusinessList.splice(0, 0, {
                        BusinessList: [], PlanData: [],
                        Controlflag: "1",
                        YX_ID: "",
                        c_seqno: null,
                        cflag: null,
                        cid: "",
                        cmemo: "Business22",
                        cname: "未选行业",
                        maxLevel: 1,
                        pid: "Business",
                        useflag: "1",
                    });

                    // var param = {};
                    // param.UserId = SiteConfig.account.id;
                    // param.pageno = 1;
                    // param.pagesize = 1000;
                    // HttpUtil.get('GovernmentPlan/PlanContentList', param).success((res) => {
                    //     if (res.state == 0) {
                    //         var PlanData = res.data;
                    //         var BusinessListData = this.BusinessList;
                    //         for (var i = 0; i < PlanData.length; i++) {
                    //             for (var j = 0; j < BusinessListData.length; j++) {
                    //                 if (PlanData[i].bussinessType == BusinessListData[j].cid) {
                    //                     PlanData[i].bussinessTypeName = BusinessListData[j].cname;
                    //                 }
                    //             }
                    //         }
                    //         vuePage.PlanData = PlanData;
                    //     } else {
                    //         this.$message({
                    //             type: 'error',
                    //             message: res.errMsg
                    //         })
                    //     }
                    // });
                }
            })

            var param = {};
            param.UserId = SiteConfig.account.id;
            param.pageno = 1;
            param.pagesize = 1000;
            HttpUtil.get('User/getGovUser', param).success((res) => {
                if (res.state == 0) {
                    var userData = res.data;
                    var DepartmentData = this.DepartmentData;
                    for (var i = 0; i < userData.length; i++) {
                        for (var j = 0; j < DepartmentData.length; j++) {
                            if (userData[i].departmentId == DepartmentData[j].DepartmentID) {
                                userData[i].DepartmentName = DepartmentData[j].DepartmentName;
                            }
                        }
                    }
                    vuePage.userData = userData;
                } else {
                    this.$message({
                        type: 'error',
                        message: res.errMsg
                    })
                }
            });
            HttpUtil.get('Department/List', {UserId: SiteConfig.account.id}).success((r) => {
                if (r.state == 0) {
                    vuePage.DepartmentData = r.data;
                }
            })

            this.getTrain();
            this.projectList();
        },
        mounted: function () {
        }
    });


</script>

</body>
</html>
